import React, { PureComponent } from 'react'

// 定义一个高阶组件
function enhanceRegionProps(WrapperComponent) {
  return props => {
    return <WrapperComponent {...props} region='中国' />
  }
}

class Home extends PureComponent {
  render() {
    return (
      <h2>Home: {`昵称: ${this.props.nickname} 等级: ${this.props.level} 区域: ${this.props.region}`}</h2>
    )
  }
}

class About extends PureComponent {
  render() {
    return (
      <h2>About: {`昵称: ${this.props.nickname} 等级: ${this.props.level} 区域: ${this.props.region}`}</h2>
    )
  }
}

const EnhanceHome = enhanceRegionProps(Home)
const EnhanceAbout = enhanceRegionProps(About)

class App extends PureComponent {
  render() {
    return (
      <div>
        App
        <EnhanceHome nickname='mm' level={90} />
        <EnhanceAbout nickname='xx' level={90} />
      </div>
    )
  }
}



export default App